import React from 'react'
import { connect } from 'react-redux'
import { add } from '../actions/countAction'

class CounterAdd extends React.Component {
  render() {
    console.log(this.props)
    return (
      <div>
        <h3>当前的Count值为：{this.props.count}</h3>
        <button onClick={this.props.Increment}>+1</button>
      </div>
    )
  }
}

function mapStateToProps(state) {
  return {
    count: state.count
  }
}

function mapDispatchToProps(dispatch) {
  return {
    Increment: () => dispatch(add(1))
  }
}

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(CounterAdd)
